﻿@model NetSurveillance.WebApp.Models.HostScanModel
@using Resources
@{
    ViewBag.Title = "白名单设置";
    Layout = "~/Views/Shared/_SimpleLayout.cshtml";
}
@section css{
    <style type="text/css">
        #div_whiteListHosts
        {
            height: 545px;
            margin-left: 10px;
            border: solid 1px #808080;
            overflow: scroll;
        }

        #nav
        {
            height: 500px;
            background: #ebebeb;
            width: 200px;
            padding: 0 0 6px 0;
            overflow: auto;
        }
    </style>
}
@section javascript
{
    <script type="text/javascript">
        function zTreeOnCheck(event, treeId, treeNode) {
            if (!treeNode.expandos || !treeNode.expandos.ip) {
                $.each(treeNode.children, function () {
                    if (treeNode.checked) {
                        $("#div_whiteListHosts").html($("#div_whiteListHosts").html() + '<p>' + this.expandos.ip + '</p>');
                        $('#selectedWhiteListIps').val($('#selectedWhiteListIps').val() + this.expandos.ip + '\r\n');
                    } else {
                        $("#div_whiteListHosts").find('p:contains("' + this.expandos.ip + '")').remove();
                        $('#selectedWhiteListIps').val($('#selectedWhiteListIps').val().replace(this.expandos.ip + '\r\n', ''));
                    }
                });
                return;
            }
            if (treeNode.checked) {
                $("#div_whiteListHosts").html($("#div_whiteListHosts").html() + '<p>' + treeNode.expandos.ip + '</p>');
                $('#selectedWhiteListIps').val($('#selectedWhiteListIps').val() + treeNode.expandos.ip + '\r\n');
            } else {
                $("#div_whiteListHosts").find('p:contains("' + treeNode.expandos.ip + '")').remove();
                $('#selectedWhiteListIps').val($('#selectedWhiteListIps').val().replace(treeNode.expandos.ip + '\r\n', ''));
            }
        }

        $(function() {
            $('#btn_showdia_qq_update').click(function () {
                $('#hostIds').val(JSON.stringify(getCheckHostIds()));
                return true;
            });
        });
    </script>
}
<div>
    <div class="showdia_qq_content">
        <div class="showdia_qq_left hostList">
            <div class="showdia_qq_left_title">
                @ViewResource.HostListTitle
            </div>
            <div class="hostListTree">
                @Html.Partial("../Host/_HostTree", ViewBag.TreeNode as string, new ViewDataDictionary{{"TreeSetting","{callback:{onCheck:zTreeOnCheck}}"}})
            </div>
        </div>
        <div class="showdia_qq_middle_right">
            <div id="div_whiteListHosts">
                @Html.Raw(ViewBag.SelectedHostHtml as string)
            </div>
        </div>
        <div class="ui-hel"></div>
        @using (Html.BeginForm("SaveSelectHosts", "WhiteList"))
        {
            @Html.ValidationSummary()
            @Html.Hidden("hostIds")
            @Html.Hidden("selectedWhiteListIps")
            <div class="showdia_qq_bottom">
                <div class="showdia_qq_bottom_btns">
                    <ul class="config_bottom_btndivs02" style="width: 280px;">
                        <li>
                            <input type="submit" value="@Resource.Button_OK" id="btn_showdia_qq_update" /></li>
                        <li>
                            @Html.ActionLink(Resource.Button_Cancel, "WhiteListSet", "WhiteList", new { @class = "commonButton" })
                        </li>
                    </ul>
                </div>
            </div>
        }
    </div>
</div>

